#include "tipwidget.h"
#include "ui_tipwidget.h"
#include <QLabel>

TipWidget::TipWidget(QString name, int flag, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TipWidget)
{
    ui->setupUi(this);

    this->setAttribute(Qt::WA_StyledBackground, true);
    this->setObjectName("widget");
    this->setStyleSheet("#widget{background-image: url(:/res/beijing.jpg);}");

    if(flag == 0)
        ui->label->setText(QString("抱歉，您借阅的《%1》目前没有了，您可以选择预约，书籍上架后会尽快通知您。").arg(name));
    else if(flag == 1)
    {
        ui->label->setText(QString("你已成功借阅《%1》请在一周之后归还。").arg(name));
    }
    else if(flag == 2)
    {
        ui->label->setText(QString("您已成功预约《%1》，书籍上架后我们会尽快通知您。").arg(name));
    }
    else if(flag == 3)
    {
        ui->label->setText(QString("您已成功还书，谢谢惠顾！"));
    }
    else if(flag == 4)
    {
        ui->label->setText(QString("积分不足，无法借阅！！"));
    }
    else if(flag == 5)
    {
        ui->label->setText(QString("图书《%1》已下架！").arg(name));
    }
}

TipWidget::~TipWidget()
{
    delete ui;
}

void TipWidget::on_pushButton_clicked()
{
    this->close();
}
